package cn.bearspark.api.service.main.impl;

import cn.bearspark.api.service.main.TagService;
import cn.bearspark.api.vo.main.tag.TagVO;
import cn.bearspark.common.constant.GlobalConstant;
import cn.bearspark.common.dto.Page;
import cn.bearspark.common.util.ConvertBeanUtil;
import cn.bearspark.tag.dto.TagDTO;
import cn.bearspark.tag.rpc.TagRpc;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @author f
 */
@Service
public class TagServiceImpl implements TagService {

    @DubboReference(check = GlobalConstant.DUBBO_CHECK)
    private TagRpc tagRpc;

    @Override
    public Page<TagVO> pageQuery(String keyword, Integer pageNum, Integer pageSize) {
        Page<TagDTO> tagDTOPage = tagRpc.pageQuery(keyword, pageNum, pageSize);
        Page<TagVO> tagVOPage = new Page<>();
        tagVOPage.setTotal(tagDTOPage.getTotal());
        tagVOPage.setRecords(ConvertBeanUtil.convertList(tagDTOPage.getRecords(), TagVO.class));
        return tagVOPage;
    }
}
